/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.plian.system.service.lg.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.plian.Tools.*;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.constant.sys.FormStatusConstant;
import com.plian.system.constant.sys.FormTypeConstant;
import com.plian.system.dao.pm.property.PropertyBasicsDao;
import com.plian.system.dto.lg.LawDisputeSummaryDTO;
import com.plian.system.entity.lg.LawDisputeSummary;
import com.plian.system.mapper.lg.LawDisputeSummaryMapper;
import com.plian.system.mybatis.base.BaseFlowService;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.mybatis.support.Condition;
import com.plian.system.pdf.OutPdf;
import com.plian.system.service.lg.ILawDisputeSummaryService;
import com.plian.system.service.sys.code.IFormCodeService;
import com.plian.system.service.sys.orgzation.OrgzationService;
import com.plian.system.service.wf.FormWorkflowService;
import com.plian.system.vo.lg.LawDisputeSummaryVO;
import com.plian.system.vo.report.HeaderVO;
import com.plian.system.vo.report.ReportReturnVO;
import com.plian.system.vo.report.ReportVO;
import com.plian.system.wrapper.lg.LawDisputeSummaryWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;

/**
 * 服务实现类
 *
 * @author gangan
 * @since 2019-09-27
 */
@Slf4j
@Service
@AllArgsConstructor
public class LawDisputeSummaryServiceImpl extends BaseServiceImpl<LawDisputeSummaryMapper, LawDisputeSummary> implements ILawDisputeSummaryService, BaseFlowService {

    private FormWorkflowService formWorkflowService;

    private OrgzationService orgzationService;

    private IFormCodeService formCodeService;

    private PropertyBasicsDao propertyBasicsDao;

    private LawDisputeSummaryWrapper lawDisputeSummaryWrapper;

    private LawDisputeSummaryMapper lawDisputeSummaryMapper;

    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public boolean saveOrUpdate(LawDisputeSummary lawDispute) {

        if (!Optional.ofNullable(lawDispute.getStatus()).isPresent()) {
            lawDispute.setStatus(FormStatusConstant.UNREVIEWED);
        }
        if (!Optional.ofNullable(lawDispute.getId()).isPresent()) {
            lawDispute.setCode(formCodeService.getCode(FormTypeConstant.LG_LAW_DISPUTE_FORM));
            lawDispute.setFormType(String.valueOf(FormTypeConstant.LG_LAW_DISPUTE_FORM));
            lawDispute.setVersion("1.0");
        }
        return super.saveOrUpdate(lawDispute);
    }

    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public boolean deleteLogic(List<Long> ids) {
        for (Long id : ids) {
            LawDisputeSummary lawDispute = getById(id);
            if (lawDispute == null) {
                return false;
            } else if (lawDispute.getStatus() != null &&
                    (lawDispute.getStatus() != FormStatusConstant.STASH && lawDispute.getStatus() != FormStatusConstant.UNREVIEWED)) {
                return false;
            }
            formWorkflowService.deleteProcessInstance(String.valueOf(id));
        }
        return super.deleteLogic(ids);
    }

    @Override
    public HashMap<String, Object> commit(String id) {
        handleStatus(Long.valueOf(id), FormStatusConstant.FLOW);

        //将需要提交的流程变量返回，用于工作流侧
        return new HashMap<String, Object>();
    }

    @Override
    public Boolean finish(String id) {
        return handleStatus(Long.valueOf(id), FormStatusConstant.FINISH);
    }

    @Override
    public Boolean reject(String id, int formState, String comment) {
        return handleStatus(Long.valueOf(id), formState);
    }


    /**
     * 统一处理状态机事件方法
     *
     * @param id           主键
     * @param updateStatus 更新状态
     * @return boolean
     */
    private Boolean handleStatus(Long id, int updateStatus) {
        try {
            LawDisputeSummary lawDispute = getById(id);
            /**
             * 设置审批人和审批时间
             */
            if (updateStatus == FormStatusConstant.FINISH) {
                lawDispute.setApprovedUser(TokenUtil.getTokenUserId());
                Date now = DateUtil.now();
                lawDispute.setApprovedTime(now);
            }
            lawDispute.setStatus(updateStatus);
            updateById(lawDispute);
            return true;
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            return false;
        }
    }

    @Override
    public Boolean checkIsExisted(Long id, String code) {
        boolean result = true;
        if (Optional.ofNullable(code).isPresent()) {
            LawDisputeSummary lawDispute = new LawDisputeSummary();
            lawDispute.setCode(code);
            if (Optional.ofNullable(getOne(Condition.getQueryWrapper(lawDispute))).isPresent()) {
                if (id == null || !id.equals(getOne(Condition.getQueryWrapper(lawDispute)).getId())) {
                    result = false;
                }
            }
        }
        return result;
    }

    @Override
    public Boolean checkTimeSpan(Long id, String year, String timeSpanId, String unitId) {
        boolean result = true;
        if (Optional.ofNullable(year).isPresent() && Optional.ofNullable(timeSpanId).isPresent()) {
            LawDisputeSummary lawDispute = new LawDisputeSummary();
            lawDispute.setFillingUnitId(unitId);
            lawDispute.setTimeSpanId(timeSpanId);
            lawDispute.setDef14(year);
            lawDispute.setIsDeleted(0);
            if (Optional.ofNullable(getOne(Condition.getQueryWrapper(lawDispute))).isPresent()) {
                if (id == null || !id.equals(getOne(Condition.getQueryWrapper(lawDispute)).getId())) {
                    result = false;
                }
            }
        }
        return result;
    }

    @Override
    public ReportReturnVO lawDisputeSummary(LawDisputeSummaryDTO lawDisputeDTO) {
        ReportReturnVO reportReturnVO = new ReportReturnVO();
        ReportVO reportVO = new ReportVO();

        reportVO
                .addHeader(HeaderVO.builder().key("fillingUnitName").title("填报单位").build())
                .addHeader(HeaderVO.builder().key("closedCasesNum").title("已结案件总数").build())
                .addHeader(HeaderVO.builder().key("amountInvolved").title("涉案总金额（万元）").build())
                .addHeader(HeaderVO.builder().key("retrieveEconomicLoss").title("挽回经济损失（万元）").build())
                .addHeader(HeaderVO.builder().key("causedEconomicLosses").title("造成经济损失（万元）").build())
                .addHeader(HeaderVO.builder().key("amountInvolvedOneHundred").title("涉案金额分类100万元以下（件）").build())
                .addHeader(HeaderVO.builder().key("amountInvolvedFiveHundred").title("涉案金额分类100万元-500万元（件）").build())
                .addHeader(HeaderVO.builder().key("amountInvolvedOneThousand").title("涉案金额分类500万元-1000万元（件）").build())
                .addHeader(HeaderVO.builder().key("amountInvolvedFiveThousand").title("涉案金额分类1000万元-5000万元（件）").build())
                .addHeader(HeaderVO.builder().key("amountInvolvedUp").title("涉案金额分类5000万元以上（件）").build())
                .addHeader(HeaderVO.builder().key("guaranteeCategory").title("担保类（件）").build())
                .addHeader(HeaderVO.builder().key("contractCategory").title("合同类（件）").build())
                .addHeader(HeaderVO.builder().key("ownershipDisputes").title("权属纠纷类（件）").build())
                .addHeader(HeaderVO.builder().key("laborDisputes").title("劳动纠纷类（件）").build())
                .addHeader(HeaderVO.builder().key("otherCategories").title("其他（件）").build())
                .addHeader(HeaderVO.builder().key("newCasesNum").title("新发生的案件结案数").build());

        List<String> longList = new ArrayList<>();
        try {
            if (StringUtil.isNotBlank(lawDisputeDTO.getSuperiorUnitsId())) {
                PageData pd = new PageData();
                pd.put("parentId", lawDisputeDTO.getSuperiorUnitsId());
                List<PageData> superiorOrg = propertyBasicsDao.findChild(pd);
                longList.add(lawDisputeDTO.getSuperiorUnitsId());
                if (CollectionUtil.isNotEmpty(superiorOrg)) {
                    for (PageData p : superiorOrg) {
                        longList.add((String) p.get("id"));
                    }
                }
            }

        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
        }

        List<LawDisputeSummaryVO> lawDisputeVOS = baseMapper.lawDisputeSummary(lawDisputeDTO.getTimeSpanId(), lawDisputeDTO.getFillingUnitIds(), longList, lawDisputeDTO.getYear());
        if (CollectionUtil.isNotEmpty(lawDisputeVOS)) {
            LawDisputeSummaryVO end = new LawDisputeSummaryVO();
            int sum = 0;
            for (LawDisputeSummaryVO vo : lawDisputeVOS) {
                sum++;
                if (vo.getClosedCasesNum() != null && vo.getClosedCasesNum() > 0) {
                    end.setClosedCasesNum(BigDecimalUtil.integerAdd(end.getClosedCasesNum(), vo.getClosedCasesNum()));
                    end.setAmountInvolved(BigDecimalUtil.add(end.getAmountInvolved(), vo.getAmountInvolved()));
                    end.setRetrieveEconomicLoss(BigDecimalUtil.add(end.getRetrieveEconomicLoss(), vo.getRetrieveEconomicLoss()));
                    end.setCausedEconomicLosses(BigDecimalUtil.add(end.getCausedEconomicLosses(), vo.getCausedEconomicLosses()));
                    end.setAmountInvolvedOneHundred(BigDecimalUtil.integerAdd(end.getAmountInvolvedOneHundred(), vo.getAmountInvolvedOneHundred()));
                    end.setAmountInvolvedFiveHundred(BigDecimalUtil.integerAdd(end.getAmountInvolvedFiveHundred(), vo.getAmountInvolvedFiveHundred()));
                    end.setAmountInvolvedOneThousand(BigDecimalUtil.integerAdd(end.getAmountInvolvedOneThousand(), vo.getAmountInvolvedOneThousand()));
                    end.setAmountInvolvedFiveThousand(BigDecimalUtil.integerAdd(end.getAmountInvolvedFiveThousand(), vo.getAmountInvolvedFiveThousand()));
                    end.setAmountInvolvedUp(BigDecimalUtil.integerAdd(end.getAmountInvolvedUp(), vo.getAmountInvolvedUp()));
                    end.setGuaranteeCategory(BigDecimalUtil.integerAdd(end.getGuaranteeCategory(), vo.getGuaranteeCategory()));
                    end.setContractCategory(BigDecimalUtil.integerAdd(end.getContractCategory(), vo.getContractCategory()));
                    end.setOwnershipDisputes(BigDecimalUtil.integerAdd(end.getOwnershipDisputes(), vo.getOwnershipDisputes()));
                    end.setLaborDisputes(BigDecimalUtil.integerAdd(end.getLaborDisputes(), vo.getLaborDisputes()));
                    end.setOtherCategories(BigDecimalUtil.integerAdd(end.getOtherCategories(), vo.getOtherCategories()));
                    end.setNewCasesNum(BigDecimalUtil.integerAdd(end.getNewCasesNum(), vo.getNewCasesNum()));
                }
            }
            end.setFillingUnitName("总计：" + (sum == 0 ? "" : sum));
            lawDisputeVOS.add(end);
        }
        reportVO.setData(lawDisputeVOS);
        reportReturnVO.setGrids(reportVO);
        return reportReturnVO;
    }
//
//    @Override
//    public ReportReturnVO unclosedCasesSummary(LawDisputeSummaryDTO lawDisputeDTO) {
//        ReportReturnVO reportReturnVO = new ReportReturnVO();
//        ReportVO reportVO = new ReportVO();
//
//        reportVO
//                .addHeader(HeaderVO.builder().key("fillingUnitName").title("填报单位").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesNum").title("未结案件总数").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolved").title("涉案总金额（万元）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolvedOneHundred").title("涉案金额分类100万元以下（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolvedFiveHundred").title("涉案金额分类100万元-500万元（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolvedOneThousand").title("涉案金额分类500万元-1000万元（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolvedFiveThousand").title("涉案金额分类1000万元-5000万元（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesAmountInvolvedUp").title("涉案金额分类5000万元以上（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesGuaranteeCategory").title("担保类（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesContractCategory").title("合同类（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesOwnershipDisputes").title("权属纠纷类（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesLaborDisputes").title("劳动纠纷类（件）").build())
//                .addHeader(HeaderVO.builder().key("unclosedCasesOtherCategories").title("其他（件）").build())
//                .addHeader(HeaderVO.builder().key("newUnclosedCasesNum").title("新发生的案件未结案数").build());
//
//        List<String> longList = new ArrayList<>();
//        try {
//            if (StringUtil.isNotBlank(lawDisputeDTO.getSuperiorUnitsId())) {
//                PageData pd = new PageData();
//                pd.put("parentId", lawDisputeDTO.getSuperiorUnitsId());
//                List<PageData> superiorOrg = propertyBasicsDao.findChild(pd);
//                longList.add(lawDisputeDTO.getSuperiorUnitsId());
//                if (CollectionUtil.isNotEmpty(superiorOrg)) {
//                    for (PageData p : superiorOrg) {
//                        longList.add((String) p.get("id"));
//                    }
//                }
//            }
//        } catch (Exception e) {
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//
//        List<LawDisputeSummaryVO> lawDisputeVOS = baseMapper.lawDisputeSummary(lawDisputeDTO.getTimeSpanId(), lawDisputeDTO.getFillingUnitIds(), longList, lawDisputeDTO.getYear());
//        if (CollectionUtil.isNotEmpty(lawDisputeVOS)) {
//            LawDisputeSummaryVO end = new LawDisputeSummaryVO();
//            int sum = 0;
//            for (LawDisputeSummaryVO vo : lawDisputeVOS) {
//                sum++;
//                if (vo.getUnclosedCasesNum() != null && vo.getUnclosedCasesNum() > 0) {
//                    end.setUnclosedCasesNum(BigDecimalUtil.integerAdd(end.getUnclosedCasesNum(), vo.getUnclosedCasesNum()));
//                    end.setUnclosedCasesAmountInvolved(BigDecimalUtil.add(end.getUnclosedCasesAmountInvolved(), vo.getUnclosedCasesAmountInvolved()));
//                    end.setUnclosedCasesAmountInvolvedOneHundred(BigDecimalUtil.integerAdd(end.getUnclosedCasesAmountInvolvedOneHundred(), vo.getUnclosedCasesAmountInvolvedOneHundred()));
//                    end.setUnclosedCasesAmountInvolvedFiveHundred(BigDecimalUtil.integerAdd(end.getUnclosedCasesAmountInvolvedFiveHundred(), vo.getUnclosedCasesAmountInvolvedFiveHundred()));
//                    end.setUnclosedCasesAmountInvolvedOneThousand(BigDecimalUtil.integerAdd(end.getUnclosedCasesAmountInvolvedOneThousand(), vo.getUnclosedCasesAmountInvolvedOneThousand()));
//                    end.setUnclosedCasesAmountInvolvedFiveThousand(BigDecimalUtil.integerAdd(end.getUnclosedCasesAmountInvolvedFiveThousand(), vo.getUnclosedCasesAmountInvolvedFiveThousand()));
//                    end.setUnclosedCasesAmountInvolvedUp(BigDecimalUtil.integerAdd(end.getUnclosedCasesAmountInvolvedUp(), vo.getUnclosedCasesAmountInvolvedUp()));
//                    end.setUnclosedCasesGuaranteeCategory(BigDecimalUtil.integerAdd(end.getUnclosedCasesGuaranteeCategory(), vo.getUnclosedCasesGuaranteeCategory()));
//                    end.setUnclosedCasesContractCategory(BigDecimalUtil.integerAdd(end.getUnclosedCasesContractCategory(), vo.getUnclosedCasesContractCategory()));
//                    end.setUnclosedCasesOwnershipDisputes(BigDecimalUtil.integerAdd(end.getUnclosedCasesOwnershipDisputes(), vo.getUnclosedCasesOwnershipDisputes()));
//                    end.setUnclosedCasesLaborDisputes(BigDecimalUtil.integerAdd(end.getUnclosedCasesLaborDisputes(), vo.getUnclosedCasesLaborDisputes()));
//                    end.setUnclosedCasesOtherCategories(BigDecimalUtil.integerAdd(end.getUnclosedCasesOtherCategories(), vo.getUnclosedCasesOtherCategories()));
//                    end.setNewUnclosedCasesNum(BigDecimalUtil.integerAdd(end.getNewUnclosedCasesNum(), vo.getNewUnclosedCasesNum()));
//                }
//            }
//            end.setFillingUnitName("总计：" + (sum == 0 ? "" : sum));
//            lawDisputeVOS.add(end);
//        }
//        reportVO.setData(lawDisputeVOS);
//        reportReturnVO.setGrids(reportVO);
//        return reportReturnVO;
//    }
//
    @Override
    public File buildpdf(Long id) {
        LawDisputeSummaryVO bean = lawDisputeSummaryWrapper.entityToVO(getById(id));
        Map<String, String> images = new HashMap<>(16);
        File file = null;

        try {
            InputStream inputStream = this.getClass().getResourceAsStream("/pdf/disputestatistics.pdf");
            //通过将文件转换为临时文件进行操作
            File model = File.createTempFile("model", ".png");
            try {
                FileUtils.copyInputStreamToFile(inputStream, model);
            } finally {
                //关闭IO
                IOUtils.closeQuietly(inputStream);
            }

            if (bean != null && model.exists()) {
                Map<String, Object> data = OutPdf.beanToMap(bean);
                data.put("def14", bean.getDef14());

                if (Optional.ofNullable(bean.getAmountInvolved()).isPresent()) {
                    data.put("newCaseAmountInvolved", bean.getNewCaseAmountInvolved() + "万元");
                }

                if (Optional.ofNullable(bean.getNewCasesNum()).isPresent()) {
                    data.put("newCasesNumStr", bean.getNewCasesNum() + "件");
                }

                if (Optional.ofNullable(bean.getUnclosedCasesAmountInvolved()).isPresent()) {
                    data.put("newUnclosedCasesAmountInvolved", bean.getNewUnclosedCasesAmountInvolved() + "万元");
                }
                if (Optional.ofNullable(bean.getNewUnclosedCasesNum()).isPresent()) {
                    data.put("newUnclosedCasesNumStr", bean.getNewUnclosedCasesNum() + "件");
                }

                String fileName = model.getPath();
                PdfReader reader = new PdfReader(fileName);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                /* 将要生成的目标PDF文件名称 */
                PdfStamper ps = new PdfStamper(reader, bos);
                /* 使用中文字体 */
                BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
                ArrayList<BaseFont> fontList = new ArrayList<>();
                fontList.add(bf);

                /* 取出报表模板中的所有字段 */
                AcroFields fields = ps.getAcroFields();
                fields.setSubstitutionFonts(fontList);
                for (String key : data.keySet()) {
                    String value = data.get(key).toString();
                    if (data.get(key) instanceof Date) {
                        value = processDate((Date) data.get(key));
                    }
                    fields.setField(key, value);
                }

                if (images != null) {
                    for (String key : images.keySet()) {
                        if (!StringUtil.isEmpty(images.get(key))) {
                            //待加入图片的文字域,设置为隐藏;不然会遮挡掉图片的
                            OutPdf.insertImage(fields, ps, key, images.get(key));
                        }
                    }
                }
                /* 必须要调用这个，否则文档不会生成的 */
                ps.setFormFlattening(true);
                ps.close();
                File dir = new File(model.getParent());
                String classFullName = bean.getClass().getName();
                file = File.createTempFile(classFullName.substring(classFullName.lastIndexOf(".")), ".pdf", dir);
                OutputStream fos = new FileOutputStream(file);
                fos.write(bos.toByteArray());
                fos.flush();
                fos.close();
                bos.close();
            }

        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
        }
        return file;
    }

    private static String processDate(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
        return date == null ? "" : format.format(date);
    }
//
//    private static String processDate2(Date date) {
//        SimpleDateFormat format = new SimpleDateFormat("yyyy");
//        return date == null ? "" : format.format(date);
//    }

    @Override
    public List<PageData> findByIds(List<String> formIds) {
        QueryWrapper<LawDisputeSummary> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id", Func.toLongList(StringUtils.join(formIds, StringPool.COMMA)));
        List<LawDisputeSummary> lawDisputes = list(queryWrapper);
        List<LawDisputeSummaryVO> lawDisputeVOS = lawDisputeSummaryWrapper.entityToVO(lawDisputes);
        List<PageData> pageDataList = new ArrayList<>();
        try {
            if (CollectionUtil.isNotEmpty(lawDisputeVOS)) {
                for (LawDisputeSummaryVO vo : lawDisputeVOS) {
                    PageData pd = new PageData();
                    pd.put("id", vo.getId());
                    pd.put("UNITNAME", vo.getFillingUnitName());
                    pd.put("APPLICANTNAME", vo.getCreateUserName());
                    pd.put("applicantId", vo.getCreateUser());
                    pd.put("applyOrganizationId", vo.getFillingUnitId());
                    pd.put("formType", FormTypeConstant.LG_LAW_DISPUTE_FORM);
                    pd.put("orgName", vo.getFillingUnitName());
                    pageDataList.add(pd);
                }
            }

            return pageDataList;
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
        }
        return pageDataList;
    }

    @Override
    public List<Integer> getFormType() {
        return Collections.singletonList(FormTypeConstant.LG_LAW_DISPUTE_FORM);
    }

    @Override
    public void goBackToStash(String formId) {
        handleStatus(Long.valueOf(formId), UNREVIEWED);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertOrUpdate(LawDisputeSummary resource) {
		LawDisputeSummary lawDisputeSummary = lawDisputeSummaryMapper.selectOne(new LambdaQueryWrapper<LawDisputeSummary>().eq(LawDisputeSummary::getSuperiorUnitsId, resource.getSuperiorUnitsId()));
		if (Objects.nonNull(lawDisputeSummary)){
		}else {
		}
		return save(resource);
	}
}
